/************************************************************
FileName:
     SM4.h
Version:
     SM4_V1.0
Date:
     Sep 13,2016
Description:
     This headfile provides macro definition, parameter definition
     and function declaration needed in SM4 algorithm implementation.

Function List:
     1. SM4_KeySchedule // Generate the required round keys
     2. SM4_Encrypt     // Encryption function
     3. SM4_Decrypt     // Decryption function
     4. SM4_SelfCheck   // Self-check

History:
     Date: Sep 13,2016
     Author: Mao Yingying, Huo Lili
     Modification:
         1) add notes to all the functions
         2) add SM4_SelfCheck function
************************************************************/

#include <stdio.h>

// rotate n bits to the left in a 32-bit buffer
#define SM4_Rotl32(buf, n) (((buf) << (n)) | ((buf) >> (32 - (n))))



extern const unsigned int SM4_CK[32];
extern const unsigned char SM4_Sbox[256];
extern const unsigned int SM4_FK[4];
// Function declarations
void SM4_KeySchedule(unsigned char MK[], unsigned int rk[]);
void SM4_Encrypt(unsigned char MK[], unsigned char PlainText[], unsigned char CipherText[]);
void SM4_Decrypt(unsigned char MK[], unsigned char CipherText[], unsigned char PlainText[]);
int SM4_SelfCheck();
